<?php
$this->registerCssFile('/css/admincategory/attrlist.css?v=0.0.3');
$this->registerJsFile('/js/admincategory/attrlist.js?v=1.0.3');
?>
<style>
	.tr-optional{display: none;}
</style>
<div class="pt15 pl15">当前位置：<span class="layui-breadcrumb"><a href="/">首页</a><a href="/admincategory/category/index">分类管理</a><a><cite>属性管理</cite></a></span></div>
<div class="layui-fluid attrlist-index">
    <div class="layui-card p30">		
		<div class="border-b pb15 f22"><span id="cate_name"></span>属性管理</div>
		<div class="mt15">
		    <span class="layui-btn layui-btn-normal" id="create-cate-attr" data-cateid="<?=$cate_id?>" data-catename="<?=$cate_name?>" href="/admincategory/category/attrcreate?attr_id=">新建属性</span>
		</div>
		<div class="layui-card-body p0">		
			<table class="layui-table mt15">
				<thead>
					<tr><th>ID</th><th>属性名称</th><th>输入方式</th><th>是否必填</th><th>备注</th><th>操作</th></tr>
				</thead>
				<tbody>
				<?php 
				if(!empty($data)){
				foreach($data as $key=>$val){ ?>
					<tr>
						<td><?= $val['id']; ?></td>
						<td><?= $val['name']; ?></td>
						<td><?= $type_arr[$val['type']]?></td>
						<td><?= $is_must_arr[$val['is_must']]?></td>
						<td><?= $val['optional']?></td>
						<td><a class="btn btn-default update-attr" data-attrid="<?= $val['id']?>">修改</a>
							<a class="btn btn-default delete-attr" data-attrid="<?= $val['id']?>">删除</a>
						</td>
					</tr>
				<?php }
				}
				?>
				</tbody>
			</table>      
		</div>		
		<div class="pt30 text-c mt15"> 
			<button type="submit" class="layui-btn layui-btn-normal"href="/admincategory/category/index">完成</button>
			<a class="layui-btn layui-btn-primary" href="/admincategory/category/index">取消</a>					
		</div>		
    </div>
</div>

<script>
	$(document).ready(function(){
		var cate_name= window.location.href.split("?")[1].split("&cate_name=")[1];
		document.getElementById('cate_name').innerHTML=decodeURI(cate_name);
	});	
</script>